<!DOCTYPE html>
<html>
<#include "/views/ftl/base/manager_include.ftl">
<script type="text/javascript" src="${basePath}js/My97DatePicker/WdatePicker.js"></script>
<base href="${basePath}">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>添加产品分类</title> 
</head>
<body style="background:#eef3f7;">
<#include "/views/ftl/base/head.ftl"> 
<div class="Main">
  <div class="dw">
<#include "/views/ftl/base/menu.ftl">
<#function a><#return "添加产品分类_List"></#function> 
<!--右边内容-->
<div class="Rightbox fl">
    <!--导航-->
    <div class="Bread_crbs clear">
      <div class="Bread_crbs_img fl"></div>
      <div class="Bread_crbs_text fl">
      	<a href="javascript:void(0);"><span>商品管理</span></a>
      	<span class="fnt_famy">></span>
      	<a href="javascript:void(0);"><span>添加产品分类</span></a>
      </div>
    </div>
       
<!--表格列表-->
<div class="Table"> 
          
           <div class="input_name" style="height:32px;    margin-bottom: 20px;">
             <span class="left_title" style="line-height: 32px;">上级分类：</span>
             <select id="first_goods_category_list_select"  class="sp">
           			<option value="0">----</option>
			 </select>
          </div>

		<div class="input_name" style="height:32px;    margin-bottom: 20px;">
			<span class="left_title" style="line-height: 32px;">能否打折：</span>
			<select id="isCanDiscount"  class="sp">
				<option value="1">能</option>
                <option value="0">不能</option>
			</select>
		</div>
          
          <div class="input_name">
             <span class="left_title">产品分类名称：</span>
             <input type="text" name="categoryName" class="search_text tdd50" style="width:210px" value=""> 
          </div>
          
          
          <span class="tbl_btn" style="margin-left: 300px;"> 
             <a href="javascript:void(0);"><span id="save" style="background: #0075c5;">保存</span></a>
          </span>
			  
        </div>
</div>  


</div>
</div>
<script> 
$(function(){


	loadfirstGoodsCategoryList();
	function loadfirstGoodsCategoryList(){
		$.ajax({ 
			url : "${basePath}manager/GoodsCategory_goodsCategoryList",
			data : { 
				pageNumber:1,
				pageSize:100
			}, 
			dataType :"JSON",
			cache : false, 
			type : "POST",
			success : function(dat){
				if(dat.code==1){
					 var html ='';
					 html+='<option value="">----</option> '; 
					 $(dat.data).each(function(index,bean){
					 	html+='<option value="'+bean.id+'">'+bean.categoryName+'</option> '; 
					 });
					 $('#first_goods_category_list_select').html(html);
				} 
			}
		});
	
	}
	
 
	
	$("#save").click(function(){
		
		var categoryName = $("input[name=categoryName]").val();  
		if(categoryName==''){
			alert("产品分类名称不能为空");
			return;
		} 
		var goodsCategoryParentId= $('#first_goods_category_list_select').val();
        var isCanDiscount= $('#isCanDiscount').val();
		$.ajax({ 
			url : "${basePath}manager/GoodsCategory_createGoodsCategory",
			data : { 
				categoryName:categoryName,
				parentId:goodsCategoryParentId,
                isCanDiscount:isCanDiscount
			}, 
			dataType :"JSON",
			cache : false,
			type : "POST",
			success : function(dat){
				if(dat.code==1){
					alert(dat.msg);
					window.location.href="${basePath}manager/GoodsCategory_goodsCategoryInfo?goodsCategoryId="+dat.data.goodsCategoryId;
				}else{
					alert(dat.msg);	
				} 
			}
		});
	});

});

</script>
</body>
</html>

